"""
1.Voice call record and playback (like a answering machine) - we only have examples for call record

A example of voice call record and play
"""

import voiceCall
import audio


f = open('usr/mia.amr','w')

def cb(para):
    if(para[2] == 1):
        read_buf = bytearray(para[1])
        voiceCall.readRecordStream(read_buf,para[1])
        f.write(read_buf,para[1])
        del read_buf
    elif(para[2] == 3):
        f.close()

voiceCall.callStart('13855169092')  # replace your phone number here

voiceCall.startRecordStream(0, 2, cb)  # start record stream


# here we play the recorded file
aud = audio.Audio(0)
aud.setVolume(11)
aud.play(2, 1, 'U:/mia.amr')
